package top.qform.config;

import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.boot.context.properties.DeprecatedConfigurationProperty;
import org.springframework.boot.convert.DataSizeUnit;
import org.springframework.boot.convert.DurationUnit;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.PropertySource;
import org.springframework.util.unit.DataSize;
import org.springframework.util.unit.DataUnit;

import java.time.Duration;
import java.time.temporal.ChronoUnit;

@ConfigurationProperties(prefix = "demo5")
@Configuration
@PropertySource(value = {"classpath:demo5.yml"}, encoding = "UTF-8", factory = YmlConfigFactory.class)
public class Demo5 {

    private Duration duration1;

    @DurationUnit(ChronoUnit.SECONDS)
    private Duration duration2;

    private DataSize dataSize1;

    @DataSizeUnit(DataUnit.MEGABYTES)
    private DataSize dataSize2;

    private String abandoned;

    public Duration getDuration1() {
        return duration1;
    }

    public void setDuration1(Duration duration1) {
        this.duration1 = duration1;
    }

    public Duration getDuration2() {
        return duration2;
    }

    public void setDuration2(Duration duration2) {
        this.duration2 = duration2;
    }

    public DataSize getDataSize1() {
        return dataSize1;
    }

    public void setDataSize1(DataSize dataSize1) {
        this.dataSize1 = dataSize1;
    }

    public DataSize getDataSize2() {
        return dataSize2;
    }

    public void setDataSize2(DataSize dataSize2) {
        this.dataSize2 = dataSize2;
    }

    @DeprecatedConfigurationProperty(reason = "has abandoned", replacement = "none")
    public String getAbandoned() {
        return abandoned;
    }

    public void setAbandoned(String abandoned) {
        this.abandoned = abandoned;
    }
}
